from fastapi import APIRouter
from fastapi.responses import JSONResponse
from pydantic import BaseModel


router = APIRouter(
    prefix="/mobot/V1",
    tags=["mobots"],
)


class UserInfo(BaseModel):
    name: str
    job: str


@router.post('/analysis',
             summary="上传用户信息",
             description="上传用户信息，姓名及工作",
             response_description="上传用户信息"
             )
def demo_rest_post_request(userInfo: UserInfo):
    # 处理业务逻辑
    name = userInfo.name
    job = userInfo.job
    result = {"code": "200", "msg": "SUCCES",
              "data": {"name": name, "age": 25, "job": job}}
    return JSONResponse(result)

# class mobotType(str, Enum):
#     business = "business"
#     story = "story"
#     qa = "qa"


# @router.get("/v1/{type}")
# def get_mobot_type(type: mobotType):
#     return {"message": f"mobot 的内容是 {type}"}

# /mobot/all


# @router.get(
#     "/all",
#     summary="取得所有的 mobots",
#     description="取得所有的 mobots，并且可以指定分页",
#     response_description="所有的 mobots 内容"
# )
# def get_mobots_all(page=1, page_size: Optional[int] = None):
#     return {"message": f"所有的 mobots： 來自第 {page} 页， 总共有 {page_size} 页"}

# # /mobot/{id}/comments/{comment_id}


# @router.get("/{id}/comments/{comment_id}", tags=["comments"])
# def get_comment(
#     id: int,
#     comment_id: int,
#     valid: bool = True,
#     username: Optional[str] = None
# ):
#     """
#     取得 mobot 的 comment 内容
#     - **id**: mobot 的 id
#     - **comment_id**: comment 的 id
#     - **valid**: comment 是否有效
#     - **username**: 使用者名称
#     """
#     return {"message": f"mobot 的 id 是：{id}， comment 的 id 是：{comment_id}， valid 是：{valid}"}


# # /mobot/type/{type}


# # @router.get("/type/{type}")
# # def get_mobot_type(type: mobotType):
# #     return {"message": f"mobot 的内容是 {type}"}

# # /mobot/{id}


# @router.get("/{id}", status_code=status.HTTP_200_OK)
# def get_mobot(id: int, response: Response):
#     if id > 5:
#         response.status_code = status.HTTP_404_NOT_FOUND
#         return {"error": f"找不到 mobot 的 id ：{id}"}
#     else:
#         response.status_code = status.HTTP_200_OK
#         return {"message": f"mobot 的 id 是：{id}"}
